/*路由器模块 */
import Vue from 'vue'
import VueRouter from 'vue-router'

import Register from '@/views/Register' 
import Home from '@/views/Home'
import Login from '@/views/Login'

import Bin from '../views/bin/Bin.vue'
import Help from '../views/help/Help.vue'
import Team from '../views/team/Team.vue'
import Workplace from '../views/workplace/Workplace.vue'
import Edit from '../views/Editor/Edit.vue'
import Mydesktop from '../views/mydesktop/MydeskTop.vue'
import Used from '../views/workplace/RecentUsed'
import MyStar from '../views/workplace/MyStar'
import MyCreated from '../views/workplace/MyCreated'
import PersonInfo from '@/views/personinfo/personinfo'
import MyCreatedTeam from '@/views/team/MyCreatedTeam'
import MyJoined from '@/views/team/MyJoined'
import TeamPage from '@/views/team/TeamPage'
import Notice from '@/views/notice/Notice'
import SearchResult from '@/views/search/SearchResult'
import TeamEdit from '@/views/Editor/TeamEdit'
import Forget from '@/views/Forget'

Vue.use(VueRouter)

const router=new VueRouter({
    //n个路由
    routes:[
        {
            path:'/register',
            component:Register
        },
        {
            path:'/home',
            component:Home,
            children:
            [
                {
                    path:'/home/workplace',
                    component:Workplace,
                    redirect:'/home/workplace/mycreated',
                    children:[
                        {
                            path:'/home/workplace/used',
                            component:Used,
                        },
                        {
                            path:'/home/workplace/mystar',
                            component:MyStar,
                        },
                        {
                            path:'/home/workplace/mycreated',
                            component:MyCreated,
                        },
                        
                    ]
                    //子路由在这里
                   
                },
                {
                    path:'/home/bin',
                    component:Bin
                },
                {
                    path:'/home/team',
                    component:Team,
                    
                    children:
                    [
                        {
                            path:'/home/team/pages',
                            component:TeamPage
                        }
                        ,
                        {
                            path:'/home/team/mycreatedteam',
                            component:MyCreatedTeam
                        },
                        {
                            path:'/home/team/myjoined',
                            component:MyJoined
                        },
                        
                    ],
                    redirect:'/home/team/pages'
                },
                {
                    path:'/home/help',
                    component:Help
                },
                {
                    path:'/home/mydesktop',
                    component:Mydesktop
                },
                {
                    path:'/home/searchresult',
                    component:SearchResult
                }
            ]
        },
        {
            path:'/login',
            component:Login
        },
        {
            path:'/',
            redirect:'/login'
        },
        {
            path:'/edit',
            component:Edit
        },
        {
            path:'/teamedit',
            component:TeamEdit
        },
        {
            path:'/person',
            component:PersonInfo
        },
        {
            path:'/notice',
            component:Notice
        },
        {
            path:'/createdteam',
            component:MyCreatedTeam
        },
        {
            path:'/joinedteam',
            component:MyJoined
        },
        {
            path:'/forget',
            component:Forget
        }
    ]
})

//挂载路由导航守卫  和后端对接还没处理好 这里暂时先注释掉 方便home页面的编写
/*
router.beforeEach((to,from,next) =>{
    //to 表示要访问的路径
    //from表示从哪个跳转出来
    //next（）放行
    if(to.path==='/login'||to.path==='/register') return next()
    //获取token
    const tokenstr=window.sessionStorage.getItem('token')
    if(!tokenstr) return next('/login')
    next()
})*/
export default router